<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">

    
      <link rel="icon" href="/hexo-book/favicon.png" />
    

    <title>
        
          OS/Linux/PXE-001 - 吧啦吧啦
        
    </title>

    <!-- Spectre.css framework -->
    <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre.min.css">
    <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-exp.min.css">
    <link rel="stylesheet" href="https://unpkg.com/spectre.css/dist/spectre-icons.min.css">

    <!-- theme css & js -->
    
<link rel="stylesheet" href="/hexo-book/css/book.css">

    
<script src="/hexo-book/js/book.js"></script>


    <!-- tocbot -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tocbot/4.4.2/tocbot.css">
    
    <!-- katex -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css">

    
    
<script src="https://cdnjs.cloudflare.com/ajax/libs/zooming/2.1.1/zooming.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
    const zooming = new Zooming()
    zooming.listen('.book-content img')
})
</script>

<meta name="generator" content="Hexo 4.2.0"></head>

<body>

<div class="book-container">
  <div class="book-sidebar">
    <div class="book-brand">
  <a href="/hexo-book/">
    <img src="/hexo-book/favicon.png">
    <span>吧啦吧啦</span>
  </a>
</div>
    <div class="book-menu">
  <h1 id="首页"><a href="/hexo-book">首页</a></h1>
<h2 id="操作系统">操作系统</h2>
<h3 id="Linux">Linux</h3>
<ul>
<li><a href="/hexo-book/OS/Linux/PXE-001">PXE 装机</a></li>
</ul>

</div>


<script src="/hexo-book/js/book-menu.js"></script>

  </div>

  <div class="sidebar-toggle" onclick="sidebar_toggle()" onmouseover="add_inner()" onmouseleave="remove_inner()">
  <div class="sidebar-toggle-inner"></div>
</div>

<script>
function add_inner() {
  let inner = document.querySelector('.sidebar-toggle-inner')
  inner.classList.add('show')  
}

function remove_inner() {
  let inner = document.querySelector('.sidebar-toggle-inner')
  inner.classList.remove('show')
}

function sidebar_toggle() {
    let sidebar_toggle = document.querySelector('.sidebar-toggle')
    let sidebar = document.querySelector('.book-sidebar')
    let content = document.querySelector('.off-canvas-content')
    if (sidebar_toggle.classList.contains('extend')) { // show
        sidebar_toggle.classList.remove('extend')
        sidebar.classList.remove('hide')
        content.classList.remove('extend')
    }
    else { // hide
        sidebar_toggle.classList.add('extend')
        sidebar.classList.add('hide')
        content.classList.add('extend')
    }
}
</script>

  <div class="off-canvas-content">
    <div class="columns">
      <div class="column col-10 col-lg-12">
        <div class="book-navbar">
          <!-- For Responsive Layout -->

<header class="navbar">
  <section class="navbar-section">
    <a onclick="open_sidebar()">
      <i class="icon icon-menu"></i>
    </a>
  </section>
</header>

        </div>
        <div class="book-content">
          <div class="book-post">
  <h1 id="PXE">PXE</h1>
<table>
<thead>
<tr>
<th>ip</th>
<th>用途</th>
</tr>
</thead>
<tbody>
<tr>
<td>172.16.8.2</td>
<td>DHCP/TFTP/HTTP(YUM)</td>
</tr>
<tr>
<td><a href="http://172.16.8.xxx" target="_blank" rel="noopener">172.16.8.xxx</a></td>
<td>客户端</td>
</tr>
</tbody>
</table>
<p>centos7 环境，PXE 客户端需 2G 内存才可以安装</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">yum -y install dhcp tftp-server syslinux xinetd <span class="comment">#安装相应的服务包</span></span><br><span class="line">sudo yum install yum-utils</span><br><span class="line">sudo yum-config-manager --add-repo https://openresty.org/package/centos/openresty.repo</span><br><span class="line">sudo yum install openresty</span><br></pre></td></tr></table></figure>
<h2 id="原理">原理</h2>
<ol>
<li>PXE 客户端发送 UDP 广播请求</li>
<li>DHCP 服务器提供信息：IP、tftp 地址、pexlinux.0位置</li>
<li>PXE 客户端向 TFTP 服务器请求下载启动文件</li>
<li>TFTP 响应并传送文件：文件中指明自动应答安装文件位置</li>
<li>PXE 客户端请求自动安装应答文件</li>
<li>PXE 客户端开始安装系统</li>
</ol>
<h2 id="DHCP">DHCP</h2>
<p>配置项 <strong>next-server、filename与 tftp 建立起关系</strong></p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># /etc/dhcp/dhcpd.conf</span></span><br><span class="line">subnet 172.16.8.0 netmask 255.255.255.0 &#123;</span><br><span class="line">    range 172.16.8.100 172.16.8.200;</span><br><span class="line">    next-server 172.16.8.2;            <span class="comment"># tftp 服务器的地址</span></span><br><span class="line">    filename <span class="string">"pxelinux.0"</span>;              <span class="comment"># PXE 文件</span></span><br><span class="line">    &#125;</span><br></pre></td></tr></table></figure>
<p>启动：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">systemctl <span class="built_in">enable</span> dhcpd             <span class="comment"># 设置开机启动</span></span><br><span class="line">systemctl restart dhcpd            <span class="comment"># 启动服务</span></span><br><span class="line"><span class="comment"># 查看正常开启 udp 67 端口</span></span><br><span class="line"><span class="comment"># 如果DHCP服务可用且客户机之间的网络正常，则执行dhclient -d eth0操作后可以观察到DHCP通信获取地址的四个过程：DHCP Discover、DHCP Offer、DHCP Request、DHCP ACK。</span></span><br></pre></td></tr></table></figure>
<p>查看 ip 地址分配情况：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">less /var/lib/dhcpd/dhcpd.leases</span><br></pre></td></tr></table></figure>
<h2 id="HTTP-YUM">HTTP (YUM)</h2>
<h3 id="使用-nginx">使用 nginx</h3>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">/usr/<span class="built_in">local</span>/openresty/nginx/conf/nginx.conf</span><br><span class="line">...</span><br><span class="line">location / &#123;</span><br><span class="line">            root   html;</span><br><span class="line">            index  index.html index.htm;</span><br><span class="line">            autoindex on;</span><br><span class="line">            autoindex_localtime on;</span><br><span class="line">        &#125;</span><br><span class="line">...</span><br></pre></td></tr></table></figure>
<h3 id="自动安装配置文件">自动安装配置文件</h3>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /usr/<span class="built_in">local</span>/openresty/nginx/html</span><br><span class="line">mkdir ksdir</span><br><span class="line">cp /root/anaconda-ks.cfg ksdir/ks7.cfg</span><br><span class="line">systemctl restart openresty</span><br><span class="line"><span class="comment">#访问 http://127.0.0.1/ksdir/ks7.cfg 能够被下载</span></span><br></pre></td></tr></table></figure>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># cat /usr/local/openresty/nginx/html/ksdir/ks7.cfg</span></span><br><span class="line"><span class="comment">#version=DEVEL</span></span><br><span class="line"><span class="comment"># System authorization information</span></span><br><span class="line">auth --enableshadow --passalgo=sha512</span><br><span class="line"><span class="comment"># SELinux configuration</span></span><br><span class="line">selinux --enforcing</span><br><span class="line"><span class="comment"># Use CDROM installation media</span></span><br><span class="line"><span class="comment">#cdrom</span></span><br><span class="line">url --url=http://172.16.8.2/centos/7</span><br><span class="line"><span class="comment"># Use graphical install</span></span><br><span class="line"><span class="comment">#graphical</span></span><br><span class="line">text</span><br><span class="line"><span class="comment"># Run the Setup Agent on first boot</span></span><br><span class="line">firstboot --<span class="built_in">enable</span></span><br><span class="line">ignoredisk --only-use=vda</span><br><span class="line"><span class="comment"># Keyboard layouts</span></span><br><span class="line">keyboard --vckeymap=cn --xlayouts=<span class="string">'cn'</span></span><br><span class="line"><span class="comment"># System language</span></span><br><span class="line">lang zh_CN.UTF-8</span><br><span class="line"></span><br><span class="line"><span class="comment"># Network information</span></span><br><span class="line"><span class="comment"># network  --bootproto=dhcp --device=eth0 --onboot=on --ipv6=auto --activate</span></span><br><span class="line">network  --bootproto=dhcp --device=eth0 --onboot=on --gateway=172.16.8.1</span><br><span class="line"><span class="comment"># network  --hostname=localhost.localdomain</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Root password</span></span><br><span class="line">rootpw --iscrypted <span class="variable">$6</span><span class="variable">$HZ</span>/K1aYu<span class="variable">$waNiNbKVJktQ5JYZQspstRf5ILF0XURenQm0</span>/IC84Rdc8akE53U8VDrP2p/25j2LTaiQ2jChKFznG8i.N1KxG.</span><br><span class="line"><span class="comment"># System services</span></span><br><span class="line"><span class="comment">#services --enabled="chronyd"</span></span><br><span class="line">services --disabled=<span class="string">"chronyd"</span></span><br><span class="line"><span class="comment"># System timezone</span></span><br><span class="line">timezone Asia/Shanghai --isUtc</span><br><span class="line"><span class="comment"># System bootloader configuration</span></span><br><span class="line">bootloader --append=<span class="string">" crashkernel=auto"</span> --location=mbr --boot-drive=vda</span><br><span class="line">autopart --<span class="built_in">type</span>=lvm</span><br><span class="line"><span class="comment"># Partition clearing information</span></span><br><span class="line">zerombr</span><br><span class="line"><span class="comment">#clearpart --none --initlabel</span></span><br><span class="line">clearpart --all</span><br><span class="line"></span><br><span class="line">%packages</span><br><span class="line">@^minimal</span><br><span class="line">@core</span><br><span class="line">chrony</span><br><span class="line">kexec-tools</span><br><span class="line">-NetworkManager</span><br><span class="line">-autofs</span><br><span class="line">%end</span><br><span class="line"></span><br><span class="line">%addon com_redhat_kdump --<span class="built_in">enable</span> --reserve-mb=<span class="string">'auto'</span></span><br><span class="line">%end</span><br><span class="line"></span><br><span class="line">%anaconda</span><br><span class="line">pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty</span><br><span class="line">pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok</span><br><span class="line">pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty</span><br><span class="line">%end</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">%post  --erroronfail</span><br><span class="line"><span class="meta">#!/usr/bin/env bash</span></span><br><span class="line">ifcfg=/etc/sysconfig/network-scripts/ifcfg-eth0</span><br><span class="line">IPADDR=$(ip ad show eth0 | grep -w inet | awk <span class="string">'&#123;print $2&#125;'</span> | cut -d<span class="string">'/'</span> -f1)</span><br><span class="line">sed -i <span class="string">"/^BOOTPROTO/c BOOTPROTO=static"</span> <span class="variable">$&#123;ifcfg&#125;</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"IPADDR=<span class="variable">$&#123;IPADDR&#125;</span>"</span> &gt;&gt; <span class="variable">$&#123;ifcfg&#125;</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"PREFIX=24"</span> &gt;&gt; <span class="variable">$&#123;ifcfg&#125;</span></span><br><span class="line"><span class="built_in">echo</span> <span class="string">"GATEWAY=172.16.8.1"</span> &gt;&gt; <span class="variable">$&#123;ifcfg&#125;</span></span><br><span class="line"><span class="comment"># systemctl stop NetworkManager</span></span><br><span class="line"><span class="comment"># systemctl disable NetworkManager</span></span><br><span class="line">systemctl restart network</span><br><span class="line">HOST=<span class="variable">$&#123;IPADDR//./-&#125;</span></span><br><span class="line"><span class="built_in">echo</span> <span class="variable">$&#123;HOST&#125;</span> &gt; /etc/hostname</span><br><span class="line"><span class="keyword">if</span> ! grep <span class="string">"<span class="variable">$&#123;IPADDR&#125;</span>    <span class="variable">$&#123;HOST&#125;</span>"</span> /etc/hosts; <span class="keyword">then</span></span><br><span class="line">    <span class="built_in">echo</span> <span class="string">"<span class="variable">$&#123;IPADDR&#125;</span>    <span class="variable">$&#123;HOST&#125;</span>"</span> &gt;&gt; /etc/hosts</span><br><span class="line"><span class="keyword">fi</span></span><br><span class="line">hostnamectl <span class="built_in">set</span>-hostname <span class="variable">$&#123;HOST&#125;</span></span><br><span class="line">%end</span><br></pre></td></tr></table></figure>
<h3 id="注意-web-权限">注意 web 权限</h3>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">find . -<span class="built_in">type</span> d -<span class="built_in">exec</span> chmod 755 &#123;&#125; \;</span><br><span class="line">find . -<span class="built_in">type</span> f -<span class="built_in">exec</span> chmod 644 &#123;&#125; \;</span><br></pre></td></tr></table></figure>
<h3 id="安装介质准备">安装介质准备</h3>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /usr/<span class="built_in">local</span>/openresty/nginx/html</span><br><span class="line">mkdir -p centos/&#123;6,7&#125;</span><br><span class="line">find . -<span class="built_in">type</span> d -<span class="built_in">exec</span> chmod 755 &#123;&#125; \;</span><br><span class="line">find . -<span class="built_in">type</span> f -<span class="built_in">exec</span> chmod 644 &#123;&#125; \;</span><br><span class="line"></span><br><span class="line">mount -o loop CentOS-7.6.1810-x86_64-DVD-1810.iso centos/7</span><br></pre></td></tr></table></figure>
<h2 id="TFTP">TFTP</h2>
<p>最终目录结构如下：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /var/lib/tftpboot</span><br><span class="line">tree</span><br><span class="line">.</span><br><span class="line">├── centos6</span><br><span class="line">├── centos7</span><br><span class="line">│   ├── initrd.img</span><br><span class="line">│   ├── vesamenu.c32</span><br><span class="line">│   └── vmlinuz</span><br><span class="line">├── pxelinux.0</span><br><span class="line">└── pxelinux.cfg</span><br><span class="line">    └── default</span><br><span class="line"></span><br><span class="line">3 directories, 5 files</span><br></pre></td></tr></table></figure>
<h3 id="TFTP-服务">TFTP 服务</h3>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># /etc/xinetd.d/tftp</span></span><br><span class="line">service tftp</span><br><span class="line">&#123;</span><br><span class="line">...</span><br><span class="line">    <span class="built_in">disable</span>     =yes         <span class="comment"># 修改这一项为"disable     =no"</span></span><br><span class="line">...</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>启动：</p>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">systemctl <span class="built_in">enable</span> tftp             <span class="comment"># 设置tftp开机启动</span></span><br><span class="line">systemctl restart tftp            <span class="comment"># 启动tftp服务</span></span><br><span class="line"><span class="comment"># 查看正常开启 udp 69 端口</span></span><br><span class="line">tftp 127.0.0.1 69                 <span class="comment"># 测试能正常连接</span></span><br></pre></td></tr></table></figure>
<h3 id="内核文件">内核文件</h3>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> /var/lib/tftpboot/</span><br><span class="line">mkdir -p centos&#123;6,7&#125;     <span class="comment"># 创建目录文件</span></span><br><span class="line">cp -f /usr/<span class="built_in">local</span>/openresty/nginx/html/centos/7/isolinux/&#123;vmlinuz,initrd.img,vesamenu.c32&#125; centos7/     <span class="comment"># 复制内核，虚拟根文件，菜单文件</span></span><br><span class="line">cp -f /usr/share/syslinux/pxelinux.0 .  <span class="comment"># pxelinux文件来自 syslinux 包，直接复制即可</span></span><br></pre></td></tr></table></figure>
<h3 id="菜单文件">菜单文件</h3>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br></pre></td><td class="code"><pre><span class="line">mkdir pxelinux.cfg</span><br><span class="line">cp /var/www/html/centos/7/isolinux/isolinux.cfg pxelinux.cfg/default <span class="comment"># 复制并改名</span></span><br><span class="line">cat pxelinux.cfg/default</span><br><span class="line">default centos7/vesamenu.c32</span><br><span class="line">timeout 100     <span class="comment"># 菜单界面等待10秒，进入默认菜单</span></span><br><span class="line"></span><br><span class="line">display boot.msg</span><br><span class="line"></span><br><span class="line"><span class="comment"># Clear the screen when exiting the menu, instead of leaving the menu displayed.</span></span><br><span class="line"><span class="comment"># For vesamenu, this means the graphical background is still displayed without</span></span><br><span class="line"><span class="comment"># the menu itself for as long as the screen remains in graphics mode.</span></span><br><span class="line">menu clear</span><br><span class="line">menu background splash.png</span><br><span class="line">menu title CentOS 7</span><br><span class="line">menu vshift 8</span><br><span class="line">menu rows 18</span><br><span class="line">menu margin 8</span><br><span class="line"><span class="comment">#menu hidden</span></span><br><span class="line">menu helpmsgrow 15</span><br><span class="line">menu tabmsgrow 13</span><br><span class="line"></span><br><span class="line"><span class="comment"># Border Area</span></span><br><span class="line">menu color border * <span class="comment">#00000000 #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Selected item</span></span><br><span class="line">menu color sel 0 <span class="comment">#ffffffff #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Title bar</span></span><br><span class="line">menu color title 0 <span class="comment">#ff7ba3d0 #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Press [Tab] message</span></span><br><span class="line">menu color tabmsg 0 <span class="comment">#ff3a6496 #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Unselected menu item</span></span><br><span class="line">menu color unsel 0 <span class="comment">#84b8ffff #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Selected hotkey</span></span><br><span class="line">menu color hotsel 0 <span class="comment">#84b8ffff #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Unselected hotkey</span></span><br><span class="line">menu color hotkey 0 <span class="comment">#ffffffff #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Help text</span></span><br><span class="line">menu color <span class="built_in">help</span> 0 <span class="comment">#ffffffff #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># A scrollbar of some type? Not sure.</span></span><br><span class="line">menu color scrollbar 0 <span class="comment">#ffffffff #ff355594 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Timeout msg</span></span><br><span class="line">menu color timeout 0 <span class="comment">#ffffffff #00000000 none</span></span><br><span class="line">menu color timeout_msg 0 <span class="comment">#ffffffff #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Command prompt text</span></span><br><span class="line">menu color cmdmark 0 <span class="comment">#84b8ffff #00000000 none</span></span><br><span class="line">menu color cmdline 0 <span class="comment">#ffffffff #00000000 none</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message.</span></span><br><span class="line"></span><br><span class="line">menu tabmsg Press Tab <span class="keyword">for</span> full configuration options on menu items.</span><br><span class="line"></span><br><span class="line">menu separator <span class="comment"># insert an empty line</span></span><br><span class="line">menu separator <span class="comment"># insert an empty line</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#label linux</span></span><br><span class="line"><span class="comment">#  menu label ^Install CentOS 7</span></span><br><span class="line"><span class="comment">#  kernel vmlinuz</span></span><br><span class="line"><span class="comment">#  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 quiet</span></span><br><span class="line">label linux</span><br><span class="line">  menu label ^Install CentOS 7</span><br><span class="line">  menu default      <span class="comment"># 设置为默认菜单</span></span><br><span class="line">  kernel centos7/vmlinuz</span><br><span class="line">  append initrd=centos7/initrd.img ks=http://172.16.8.2/ksdir/ks7.cfg net.ifnames=0 biosdevname=0 ksdevice=eth0     <span class="comment"># 与 yum 建立联系</span></span><br><span class="line"></span><br><span class="line">label check</span><br><span class="line">  menu label Test this ^media &amp; install CentOS 7</span><br><span class="line">  <span class="comment">#menu default</span></span><br><span class="line">  kernel vmlinuz</span><br><span class="line">  append initrd=centos7/initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet   <span class="comment"># 需要则改</span></span><br><span class="line"></span><br><span class="line">menu separator <span class="comment"># insert an empty line</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># utilities submenu</span></span><br><span class="line">menu begin ^Troubleshooting</span><br><span class="line">  menu title Troubleshooting</span><br><span class="line"></span><br><span class="line">label vesa</span><br><span class="line">  menu indent count 5</span><br><span class="line">  menu label Install CentOS 7 <span class="keyword">in</span> ^basic graphics mode</span><br><span class="line">  text <span class="built_in">help</span></span><br><span class="line">    Try this option out <span class="keyword">if</span> you<span class="string">'re having trouble installing</span></span><br><span class="line"><span class="string">    CentOS 7.</span></span><br><span class="line"><span class="string">  endtext</span></span><br><span class="line"><span class="string">  kernel vmlinuz</span></span><br><span class="line"><span class="string">  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">label rescue</span></span><br><span class="line"><span class="string">  menu indent count 5</span></span><br><span class="line"><span class="string">  menu label ^Rescue a CentOS system</span></span><br><span class="line"><span class="string">  text help</span></span><br><span class="line"><span class="string">    If the system will not boot, this lets you access files</span></span><br><span class="line"><span class="string">    and edit config files to try to get it booting again.</span></span><br><span class="line"><span class="string">  endtext</span></span><br><span class="line"><span class="string">  kernel vmlinuz</span></span><br><span class="line"><span class="string">  append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rescue quiet</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">label memtest</span></span><br><span class="line"><span class="string">  menu label Run a ^memory test</span></span><br><span class="line"><span class="string">  text help</span></span><br><span class="line"><span class="string">    If your system is having issues, a problem with your</span></span><br><span class="line"><span class="string">    system'</span>s memory may be the cause. Use this utility to</span><br><span class="line">    see <span class="keyword">if</span> the memory is working correctly.</span><br><span class="line">  endtext</span><br><span class="line">  kernel memtest</span><br><span class="line"></span><br><span class="line">menu separator <span class="comment"># insert an empty line</span></span><br><span class="line"></span><br><span class="line">label <span class="built_in">local</span></span><br><span class="line">  menu label Boot from ^<span class="built_in">local</span> drive</span><br><span class="line">  localboot 0xffff</span><br><span class="line"></span><br><span class="line">menu separator <span class="comment"># insert an empty line</span></span><br><span class="line">menu separator <span class="comment"># insert an empty line</span></span><br><span class="line"></span><br><span class="line">label returntomain</span><br><span class="line">  menu label Return to ^main menu</span><br><span class="line">  menu <span class="built_in">exit</span></span><br><span class="line"></span><br><span class="line">menu end</span><br></pre></td></tr></table></figure>
<h3 id="注意-tftp-权限">注意 tftp 权限</h3>
<figure class="highlight sh"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">find . -<span class="built_in">type</span> d -<span class="built_in">exec</span> chmod 755 &#123;&#125; \;</span><br><span class="line">find . -<span class="built_in">type</span> f -<span class="built_in">exec</span> chmod 644 &#123;&#125; \;</span><br></pre></td></tr></table></figure>

</div>


  <div class="book-comments">
    




  </div>



<script src="/hexo-book/js/book-post.js"></script>

        </div>
      </div>
      <div class="column col-2 hide-lg">
        <div class="book-post-info">
  
    <div class="book-post-meta">

  <div class="author">

    <!-- Author image -->
    <div class="author-img">
      
        <figure
          class="avatar avatar-lg"
          data-initial="S"
          style="background-color: #3b4351;">
        </figure>
      
    </div>

    <!-- Author title -->
    <div class="author-title">
      <div>S1</div>
      <div>2020-04-10</div>
    </div>
  </div>

  

  <div class="divider"></div>
</div>
  

  <div class="book-tocbot">
</div>
<div class="book-tocbot-menu">
  <a class="book-toc-expand" onclick="expand_toc()">全部展开</a>
  <a onclick="go_top()">返回顶部</a>
  <a onclick="go_bottom()">去底部</a>
</div>


<script src="/hexo-book/js/book-toc.js"></script>


</div>
      </div>
    </div>
  </div>
  
  <a class="off-canvas-overlay" onclick="hide_canvas()"></a>
</div>

</body>
</html>


<script src="/hexo-book/js/book.js"></script>
